Skip to content

Improve handling for invalid core files - #358

Open
godlygeek wants to merge 2 commits into
bloomberg:mainfrom
godlygeek:handle_bad_core_files
Open

godlygeek wants to merge 2 commits into
bloomberg:mainfrom
godlygeek:handle_bad_core_files

Conversation

@godlygeek

@godlygeek godlygeek commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Prevent reading past the end of a truncated or malformed core file's NT_FILE note.

@godlygeek godlygeek self-assigned this Sep 17, 2026
@godlygeek
godlygeek requested a review from a team September 17, 2026 22:42
@codecov-commenter

codecov-commenter commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.75%. Comparing base (a0ec380) to head (5cec815).

Files with missing lines Patch % Lines
src/pystack/_pystack/corefile.cpp 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
+ Coverage   78.19%   78.75%   +0.56%     
==========================================
  Files          58       58              
  Lines        6690     6709      +19     
  Branches      630      632       +2     
==========================================
+ Hits         5231     5284      +53     
+ Misses       1459     1425      -34     
Flag Coverage Δ
cpp 78.75% <93.54%> (+0.56%) ⬆️
python 78.75% <93.54%> (+0.56%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@godlygeek
godlygeek requested a review from pablogsal September 17, 2026 22:53
@godlygeek
godlygeek force-pushed the handle_bad_core_files branch 2 times, most recently from d51c2b6 to cf28439 Compare September 18, 2026 17:18
@godlygeek godlygeek changed the title Improve handling for unsupported core files Improve handling for invalid core files Sep 18, 2026
Prevent reading past the end of a truncated or malformed core file's
`NT_FILE` note.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@godlygeek
godlygeek force-pushed the handle_bad_core_files branch from cf28439 to 11d9cb4 Compare September 18, 2026 18:16
Comment thread src/pystack/_pystack/corefile.cpp
Comment thread src/pystack/_pystack/corefile.cpp
Comment thread src/pystack/_pystack/corefile.cpp
Comment thread src/pystack/_pystack/corefile.cpp Outdated
// File names are stored at the end of the main table
const char* filename_table_start = ptr + count * entry_size;
const char* filename_table_ptr = filename_table_start;
const char* filename_table_ptr = ptr + count * entry_size;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Consider renaming to filename_start, it will make later uses with filename_end cleaner.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With one name, we have to choose which of two things to make clearer:

  • That there is a table of file names which we are iterating through
  • That our pointer points to the start of the current name cstring in that table

I think the rename you're suggesting makes the more obvious thing clearer, at the cost of obscuring the much less obvious and weirder thing - that we're iterating through N null-terminated strings all concatenated to each other.

How about calling our main iterator into the table next_file, and our pointer to the end of the first C string it points to next_file_end?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point.

I like "next" for kind of linked-list semantics. Would be nice to have "filename" instead of "file", and would be nice to have _start suffix on the first variable for symmetry with _end suffix, which I think does not affect the linked-list semantics.

My preference order would be:

  1. next_filename_start/next_filename_end
  2. next_filename/next_filename_end
  3. next_file_start/next_file_end
  4. next_file/next_file_end

@godlygeek

godlygeek commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

OK, I've pushed a fixup commit that I believe addresses all of your concerns. If you're happy with the results, lmk and I'll squash and merge.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants